"""
@author: gaoyx
@date: 2021-12-24 16:32:39
"""
<!-- card风格样式 -->
<template>
  <div class="card" :class="{
      unread: isUnread
    }" :style="{ minHeight }" @click="onClick">
    <div class="card-title" v-if="title" :style="isShow?'padding-bottom:20px':''">
      <h3 v-if="isShow">{{ title }}</h3>
      <h3 v-else>{{ title | ellipsis(32) }}</h3>
      <img class="icon " v-if="isShow && title.length > 32" @click.stop="isShow = false" src="../../assets/images/fold.png" />
      <img class="icon" v-if="!isShow && title.length > 32" @click.stop="isShow = true" src="../../assets/images/unfold.png" />
    </div>
    <slot></slot>
    <slot name="footer"></slot>
  </div>
</template>

<script>
export default {
  name: 'card',
  props: {
    minHeight: {
      type: String,
      default: '142px'
    },
    title: {
      type: String,
      default: ''
    },
    layout: {
      type: String,
      default: 'inline'
    },
    isUnread: {
      type: Boolean,
      default: false
    },
    colon: {
      type: Boolean,
      default: undefined
    }
  },
  provide () {
    return {
      context: this
    }
  },
  data () {
    return {
      isShow: false
    }
  },
  methods: {
    onClick () {
      this.$emit('click')
    },
    onExpand () { },
    onPackup () { }
  }
}
</script>

<style lang='scss' scoped>
.card {
  margin: 15px 10px 0 11px;
  padding: 20px;
  background: #fff;
  border-radius: $border-radius;
}
.unread {
  position: relative;
  &::before {
    content: '';
    width: 8px;
    height: 8px;
    background-color: red;
    border-radius: 50%;
    display: block;
    position: absolute;
    top: 12px;
    right: 12px;
  }
}
.card-title {
  position: relative;
  h3 {
    line-height: 24px;
    font-size: 17px;
    margin: 0 0 10px 0;
  }
  .icon {
    position: absolute;
    height: 12px;
    width: 12px;
    right: 15px;
    bottom: 6px;
 
  }
}
</style>